#include "apue.h"

int g_val = 50;

int main() {
    int val = 100;
    pid_t pid;

    pid = fork();
    if (pid < 0) {
        err_sys("fork error");
    } else if (pid == 0) {
        // child process
        val++;
        g_val++;
        exit(0);
    }
    // parent process
    sleep(1);
    printf("g_val = %d, val = %d\n", g_val, val);

    return 0;
}
